package flc.ast.fragment;

import android.os.Bundle;

import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.GridLayoutManager;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.chad.library.adapter.base.BaseQuickAdapter;

import java.util.ArrayList;
import java.util.List;

import flc.ast.R;
import flc.ast.activity.DrawActivity;
import flc.ast.adapter.MaterialAdapter;
import flc.ast.databinding.FragmentDrawBinding;
import stark.common.basic.base.BaseNoModelFragment;
import stark.common.basic.event.EventStatProxy;

/**
 * A simple {@link Fragment} subclass.
 * Use the {@link DrawFragment#newInstance} factory method to
 * create an instance of this fragment.
 */
public class DrawFragment extends BaseNoModelFragment<FragmentDrawBinding> {

    private MaterialAdapter materialAdapter;

    @Override
    protected int onCreate() {
        return R.layout.fragment_draw;
    }

    @Override
    protected void initView() {
        EventStatProxy.getInstance().statEvent1(getActivity(), mDataBinding.event1Container);

        mDataBinding.ivDraw.setOnClickListener(this);

        mDataBinding.rvMaterialList.setLayoutManager(new GridLayoutManager(mContext, 2));
        materialAdapter = new MaterialAdapter();
        mDataBinding.rvMaterialList.setAdapter(materialAdapter);
        materialAdapter.setOnItemClickListener(this);
    }

    @Override
    protected void onItemClickCallback(@NonNull BaseQuickAdapter<?, ?> adapter, @NonNull View view, int position) {
        DrawActivity.img = materialAdapter.getItem(position);
        DrawActivity.isImitation = true;
        startActivity(DrawActivity.class);
    }

    @Override
    protected void onClickCallback(View v) {
        switch (v.getId()) {
            case R.id.ivDraw://自由画板
                DrawActivity.isImitation = false;
                startActivity(DrawActivity.class);
                break;
        }
    }

    @Override
    protected void initData() {
        List<Integer> list = new ArrayList<>();
        list.add(R.drawable.a01);
        list.add(R.drawable.a02);
        list.add(R.drawable.a03);
        list.add(R.drawable.a04);
        list.add(R.drawable.a05);
        list.add(R.drawable.a06);
        list.add(R.drawable.a07);
        list.add(R.drawable.a08);
        list.add(R.drawable.a09);
        list.add(R.drawable.a10);
        list.add(R.drawable.a11);
        list.add(R.drawable.a12);
        list.add(R.drawable.a13);
        list.add(R.drawable.a14);
        list.add(R.drawable.a15);
        list.add(R.drawable.a16);
        list.add(R.drawable.a17);
        list.add(R.drawable.a18);
        list.add(R.drawable.a19);
        list.add(R.drawable.a20);
        list.add(R.drawable.a21);
        list.add(R.drawable.a22);
        list.add(R.drawable.a23);
        list.add(R.drawable.a24);
        list.add(R.drawable.a25);
        list.add(R.drawable.a26);
        list.add(R.drawable.a27);
        list.add(R.drawable.a28);
        materialAdapter.setList(list);
    }
}